//
//  CustomerOrderDetailCell1.m
//  WGFGlobalHouses
//
//  Created by waiguofang on 15/6/12.
//  Copyright (c) 2015年 waiguofang. All rights reserved.
//

#import "CustomerOrderDetailCell1.h"
#import "ProgressView.h"
#import "OrderDetailData.h"
#import "UIImageView+WebCache.h"
#import "config.h"
#import "NSString+StringHight.h"

@interface CustomerOrderDetailCell1()
@property (nonatomic,strong)ProgressView *proView;

@property (weak, nonatomic) IBOutlet UIView *progressContentView;


@property (weak, nonatomic) IBOutlet UIImageView *buyerImgView;

@property (weak, nonatomic) IBOutlet UILabel *buyerName;

@property (weak, nonatomic) IBOutlet UITextView *buyerMobile;


@property (weak, nonatomic) IBOutlet UILabel *orderCodeLab;

@property (weak, nonatomic) IBOutlet UILabel *timeLab;

@property (weak, nonatomic) IBOutlet UIImageView *imgView;

@property (weak, nonatomic) IBOutlet UILabel *mianTitleLab;

@property (weak, nonatomic) IBOutlet UILabel *subTitleLab;

@property (weak, nonatomic) IBOutlet UILabel *dorLab;

@property (weak, nonatomic) IBOutlet UILabel *rmbLab;

@property (weak, nonatomic) IBOutlet UIImageView *sellerImg;
@property (weak, nonatomic) IBOutlet UILabel *sellerNamelab;
@property (weak, nonatomic) IBOutlet UITextView *sellerMobiletf;
@property (weak, nonatomic) IBOutlet UIView *shangjiaBg;
//卖家地址
@property (weak, nonatomic) IBOutlet UILabel *sellerAdd;
//买家地址
@property (weak, nonatomic) IBOutlet UILabel *buyerAdd;
@property (weak, nonatomic) IBOutlet UIView *buyerView;
@property (weak, nonatomic) IBOutlet UIView *sellerView;

@end
@implementation CustomerOrderDetailCell1

+(instancetype) cellWithTableView:(UITableView *)tableview{
    
    static NSString *ID = @"CustomerOrderDetailCell1";
    CustomerOrderDetailCell1 *cell = [tableview dequeueReusableCellWithIdentifier:ID];
    [cell.shangjiaBg setBackgroundColor:[UIColor colorWithPatternImage:[UIImage imageNamed:@"2bg"]]];
    if (cell == nil)
    {
        cell = [[[NSBundle mainBundle]loadNibNamed:@"CustomerOrderDetailCell1" owner:nil options:nil]lastObject];
        
        [cell setSelectionStyle:UITableViewCellSelectionStyleNone];
        
         cell.proView = [ProgressView creatView];
        
        int mid = cell.progressContentView.frame.size.height-cell.proView.frame.size.height;
        
       
        [cell.proView setFrame:CGRectMake(0,mid/2, cell.progressContentView.frame.size.width, cell.progressContentView.frame.size.height-mid)];
        [cell.progressContentView addSubview:cell.proView];
        
        [[cell  buyerMobile]setTintColor:UIColorFromRGB(0x333333)];
        cell.buyerMobile.editable = NO;
        [cell.buyerMobile setScrollEnabled:false];
        
        [[cell sellerMobiletf]  setTintColor:UIColorFromRGB(0x333333)];
        cell.sellerMobiletf.editable = NO;
        [cell.sellerMobiletf setScrollEnabled:false];
        
        [cell.buyerView setBackgroundColor:[UIColor colorWithPatternImage:[UIImage imageNamed:@"2bg"]]];
        [cell.sellerView setBackgroundColor:[UIColor colorWithPatternImage:[UIImage imageNamed:@"2bg"]]];
    }
    
    return cell;
}


+(CGFloat)getHight:(CellBaseData*)data withTableView:(UITableView*)tableView{
    
    return 503 - 26;
}

-(void)setData:(OrderDetailData*)data{
    

    self.sellerAdd.text = data.sellerAddress;
    self.buyerAdd.text = data.buyerAddress;
    [self.proView setPogressState:data.state];
    
    [self.buyerImgView sd_setImageWithURL:[NSURL URLWithString:data.buyerImg] placeholderImage:[UIImage imageNamed:DEFAULT_IMG]];
    
    [self.buyerName setText:data.buyerName];
    
    
    NSMutableAttributedString *attString = [data.buyerMobile attributedStringFromStingWithFont:self.buyerMobile.font withLineSpacing:0];
    NSRange contentRange = {0, [attString length]};
    [attString addAttribute:NSUnderlineStyleAttributeName value:[NSNumber numberWithInteger:NSUnderlineStyleSingle] range:contentRange];
    [attString addAttribute: NSForegroundColorAttributeName value: [UIColor blueColor] range:contentRange];
    [self.buyerMobile setAttributedText:attString];
    [self.buyerMobile setText:data.buyerMobile];
    
    
    [self.orderCodeLab setText:[NSString stringWithFormat:@"订单编号:%@",data.orderCode]];
    [self.timeLab setText:data.time];
    [self.imgView sd_setImageWithURL:[NSURL URLWithString:data.imgPath] placeholderImage:[UIImage imageNamed:DEFAULT_IMG]];
    [self.mianTitleLab setText:data.title];
    [self.subTitleLab setText:data.subleTitle];
    [self.dorLab setText:data.dol];
    [self.rmbLab setText:[NSString stringWithFormat:@"约:¥%@万",data.rmb]];
    
    [self.sellerImg sd_setImageWithURL:[NSURL URLWithString:data.salerImg] placeholderImage:[UIImage imageNamed:DEFAULT_IMG]];
    [self.sellerNamelab setText:data.salerName];
    
    
    
    attString = [data.salerMobile attributedStringFromStingWithFont:self.buyerMobile.font withLineSpacing:0];
    NSRange contentRange2 = {0, [attString length]};
    [attString addAttribute:NSUnderlineStyleAttributeName value:[NSNumber numberWithInteger:NSUnderlineStyleSingle] range:contentRange2];
    [attString addAttribute: NSForegroundColorAttributeName value: [UIColor blueColor] range: contentRange2];
    [self.sellerMobiletf setAttributedText:attString];
    
}




@end
